package net.pimpas.report.processor.condition.impl;

import java.util.List;

import net.pimpas.report.processor.condition.AbstractCondition;
import net.pimpas.report.processor.condition.ConditionType;
import net.pimpas.report.processor.exception.ConditionException;
import net.pimpas.report.processor.field.Field;
import net.pimpas.report.processor.resolver.FieldPropertyResolver;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

public class InCondition extends AbstractCondition {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2598781260041265300L;
	private List<Object> inValues;
	
	public InCondition(Field field, List<Object> values) {
		super(field, ConditionType.IN);
		this.setInValues(values);
	}

	@Override
	public Criterion process(String fieldAlias, FieldPropertyResolver resolver) throws ConditionException {
		return Restrictions.in(fieldAlias, this.getInValues());
	}

	public List<Object> getInValues() {
		return inValues;
	}

	public void setInValues(List<Object> inValues) {
		this.inValues = inValues;
	}
	
	@Override
	public Object[] getValues() {
		return this.getInValues().toArray();
	}
}